<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>变量作用域</title>
		<script>
			//全局变量
			//var i = 10;
			
			function myfn(){
				//局部变量,生命周期在定义它的范围之内
				//var i = 100;
				
				//修改全局变量的值
				i = 100;
				
				/**
				 * 结论: 
				 * 在函数内部定义的局部变量,如果不使用var,则该变量就是全局的!
				 */
			}
			
			myfn();
			
			//Uncaught ReferenceError: i is not defined
			alert(i);
		</script>
	</head>
	<body>
		
	</body>
</html>
